package org.raftkv.raft.core.node;


import org.raftkv.raft.core.enums.StateType;

import java.util.Objects;

/**
 * 软状态是易变的，包括：当前集群 leader、当前节点状态
 * <BR/>
 * 这部分数据不需要存储到持久化中
 *
 * @author wzy
 */
public class SoftState {

    private long lead;

    private StateType raftState;

    private StateType nodeState;

    public SoftState(long lead, StateType nodeState) {
        this.lead = lead;
        this.nodeState = nodeState;
    }

    public long getLead() {
        return lead;
    }

    public StateType getNodeState() {
        return nodeState;
    }

    public StateType getRaftState() {
        return raftState;
    }

    public void setRaftState(StateType raftState) {
        this.raftState = raftState;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        SoftState softState = (SoftState) o;
        return lead == softState.lead &&
                nodeState == softState.nodeState;
    }

    @Override
    public int hashCode() {
        return Objects.hash(lead, nodeState);
    }

}
